package pattern.creational.singleton.simple;

import java.util.Vector;

/**
 * @author: chaoyang.ren
 * @date:Jul 13, 2017
 * @time:2:54:29 PM
 * @email:chaoyang.ren@foxmail.com
 * @version: 1.0
 */
public class SingletonClass {
	private static SingletonClass instance = null;

	private SingletonClass() {
	}

	private static synchronized void syncInit() {
		if (instance == null) {
			instance = new SingletonClass();
		}
	}

	public static SingletonClass getInstance() {
		if (instance == null) {
			syncInit();
		}
		return instance;
	}

	// 采用"影子实例"的办法为单例对象的属性同步更新
	private Vector<?> properties = null;
	public Vector<?> getProperties() {
		return properties;
	}
	public void updateProperties() {
		SingletonClass shadow = new SingletonClass();
		properties = shadow.getProperties();
	}
}
